﻿using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyCore.Authorizations
{
    /// <summary>
    /// 其它认证授权处理器
    /// </summary>
    public class MinimumAgeAnotherAuthorizationHandler : AuthorizationHandler<MinimumAgeRequirement>
    {
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, MinimumAgeRequirement requirement)
        {
            var isBoss = context.User.IsInRole("InternetBarBoss");

            if (isBoss)
            {
                context.Succeed(requirement);
            }

            return Task.CompletedTask;
        }
    }
}
